package midlets;

import javax.microedition.lcdui.Command;
import javax.microedition.lcdui.CommandListener;
import javax.microedition.lcdui.Display;
import javax.microedition.lcdui.Displayable;
import javax.microedition.media.Player;
import javax.microedition.midlet.MIDlet;
import javax.microedition.midlet.MIDletStateChangeException;

import rmsstream.RMSBuffer;


public class MediaPlayer extends MIDlet implements CommandListener {

	public static Player player = null;
	public static Display display = null;

	public MediaPlayer() {
		display = Display.getDisplay(this);
	}

	protected void destroyApp(boolean arg0) throws MIDletStateChangeException {
		// TODO Auto-generated method stub

	}

	protected void pauseApp() {
		// TODO Auto-generated method stub

	}

	protected void startApp() throws MIDletStateChangeException {
		RMSBuffer rmsb = new RMSBuffer();
		System.out.println("ADDING VIDEOS:");
		rmsb.addVideo("http://host/test11.3gp", "video/3gpp");
		rmsb.addVideo("http://host/test12.3gp", "video/3gpp");

		Thread rmsb_thread = new Thread(rmsb);
		rmsb_thread.start();
	}

	public void commandAction(Command arg0, Displayable arg1) {

	}

	public static void stopPlayer() {
		try {
			player.stop();
		} catch (Exception e) {
			e.printStackTrace();
		}
	}

}
